﻿package  {
	import flash.text.GridFitType;
	
	public class FuseFactory {
		
		// Constants:
		// Public Properties:
		// Private Properties:
		private var fuseDensity:Number; //Sets the amount of FuseOrbs to be spawned on screen
	
		// Initialization:
		public function FuseFactory():void {
		}
	
		// Public Methods:
		//fillFuseArray: 
		//This function fills up the Grid array by placing FuseOrbs at random
		//spots on the grid below the fifth row from the top.
		public function fillFuseArray(grid:Grid, fuseAmount:Number){
			var i:Number = 0;
			var tempX:int = 0;
			var tempY:int = 0;
			var tempType:int = 0;
			fuseDensity = fuseAmount;
			do{
				tempX = Math.round(Math.random()*7);
				tempY = Math.round(Math.random() * 10) + 5;
				tempType = Math.ceil((Math.random() * 30) / 10);
				if(!grid.hasOrbThere(tempX, tempY)){
					var newFuse:FuseOrb = new FuseOrb(tempX, tempY, tempType);
					grid.addFuseOrb(newFuse);
					i++;
				}
			}while(i < fuseDensity);
		}
		
		// Protected Methods:
	}
	
}